import { Range } from 'immutable';
import { Block } from '@design/core';
import TYPE from '@design/constant/component-type';

export function createTable(rows = 3, columns = 3) {
  const rowNodes = Range(0, rows)
    .map(() => createRow(columns))
    .toList();
  return Block.create({
    type: TYPE.TABLE,
    nodes: rowNodes,
    data: {
      rowCount: 3,
      columnCount: 3,
    },
    style: {
      height: 'auto', 
      width: '338px',
    },
  });
}

export function createRow(columns = 3) {
  const cellNodes = Range(0, columns)
    .map(createCell)
    .toList();
  return Block.create({
    type: TYPE.TABLE_ROW,
    nodes: cellNodes,
    style: {},
  });
}

export function createCell() {
  return Block.create({
    type: TYPE.TABLE_CELL,
    style: {
      height: '100px',
      width: '100%', 
    },
  });
}
